<?php
namespace app\index\controller;

use think\Controller;
use think\Request;
use think\Db;

class Goods extends Controller
{   
    public function _initialize()
    {
        parent::_initialize();
    }

    public function index($id = '1')
    {   
        $info = DB::name('goods')
            ->field('gName, gNum, mPrice, gDesc, cId')
            ->alias('a')
            ->where('id', $id)
            ->select();
            
        $album = DB::name('album')
            ->field('albumPath')
            ->where('gid', 2)
            ->select();
        $list = $info[0];
        $this->assign('list', $list);
        $this->assign('album', $album);
    	return $this->fetch();
    }

    private function getAlbumPath($gid, $color = '1')
    {   
        $map['gid']   = $gid;
        $map['color'] = $color;
        $album = DB::name('album')
            ->field('albumPath')
            ->where('gid', $gid)
            ->select();
        return $album;
    }
}
